package com.hj.system.system.controller;

import java.util.Map;

import com.hj.system.base.utils.ResponseUtil;
import com.hj.system.system.service.UserFingerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hj.system.base.utils.PageUtils;
import org.springframework.stereotype.Controller;
import com.hj.system.system.domain.UserFingerDO;

/**
 * 用户与角色对应关系
 *
 * @author wxf
 * @email 123@123.com
 * @date 2019-07-24 15:39:15
 */

@Controller
@RequestMapping("/user/finger")
public class UserFingerController {
    @Autowired
    private UserFingerService userFingerService;

    @GetMapping
    @RequiresPermissions("sys:user:finger")
    public String SysUserFingerprint(Model model, String userId) {
        if (!"".equals(userId)) {
            model.addAttribute("userId", userId);
        }
        return "system/userFinger/userFinger";
    }


    /**
     * 分页查询
     */
    @ResponseBody
    @GetMapping("/list")
    public Map<String, Object> list(@RequestParam Map<String, Object> params) {
        PageUtils pageUtils = userFingerService.list(params);
        return ResponseUtil.okContent(pageUtils);
    }

    /**
     * 保存
     */
    @ResponseBody
    @PostMapping("/save")
    public ResponseUtil save(UserFingerDO sysUserFingerprint) {
        if (userFingerService.save(sysUserFingerprint) > 0) {
            return ResponseUtil.ok();
        }
        return ResponseUtil.error();
    }

    /**
     * 删除
     */
    @PostMapping("/remove/{id}")
    @ResponseBody
    public ResponseUtil remove(@PathVariable("id") Long id) {
        if (userFingerService.remove(id) > 0) {
            return ResponseUtil.ok();
        }
        return ResponseUtil.error();
    }
}
